package com.zxy.supplier_system.server.entity

import jakarta.persistence.CascadeType
import jakarta.persistence.Entity
import jakarta.persistence.FetchType
import jakarta.persistence.Id
import jakarta.persistence.JoinColumn
import jakarta.persistence.MapsId
import jakarta.persistence.OneToMany
import jakarta.persistence.OneToOne

@Entity
class MarketSettlementPlan {

    @Id
    var marketId: Int? = null

    @MapsId
    @OneToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "market_id")
    lateinit var market: Market

    @OneToMany(fetch = FetchType.LAZY, mappedBy = "plan", orphanRemoval = true, cascade = [CascadeType.ALL])
    var rules: MutableList<MarketSettlementRule> = mutableListOf()

}